# Maintainer: Sergej Pupykin <pupykin.s+arch@gmail.com>
# Contributor: Sean Timothy Noonan <stnoonan@obsolescence.net>

pkgname=postgrey
pkgver=1.37
pkgrel=5
pkgdesc="a Postfix policy server implementing greylisting"
arch=('any')
url="https://postgrey.schweikert.ch/"
options=(emptydirs)
license=("GPL")
depends=(perl perl-{berkeleydb,io-multiplex,net-server,netaddr-ip})
optdepends=('postfix: the recommended MTA for use with postgrey'
	    'exim: an alternative MTA'
	    'perl-net-dns: for postgreyreport tool')
backup=(etc/postfix/postgrey_whitelist_recipients
	etc/postfix/postgrey_whitelist_clients)
source=($url/pub/$pkgname-$pkgver.tar.gz
	postgrey.service
	postgrey.sysusers
	postgrey.tmpfiles
	untaint.patch)
sha256sums=('ff4d9543f8f5cb0356c30ffe22255d942ac6128da734c376de211c02630fa5f7'
            'd36c73b6a8ba96ba3eaa3e56098afda828ee56ec12000d3392ab450246d38e09'
            '859380a05ca55e1d07e1e38f16244adfa8cde9987414df9785206bddc84137cc'
            '089a597a8faa92c9f910c00398f0ecb77b6573307fdb7c1989138d9af7c95ed0'
            'e5f80653c02681b54f28051104f1ce45991b014a86965610611b1b4921284bd7')

prepare() {
  cd "$srcdir"/$pkgname-$pkgver
  patch -p0 <"$srcdir"/untaint.patch
}

package() {
  cd "$srcdir"/$pkgname-$pkgver
  install -D -m 0755 postgrey "$pkgdir"/usr/bin/postgrey
  install -D -m 0755 contrib/postgreyreport "$pkgdir"/usr/bin/postgreyreport
  install -D -m 0644 postgrey_whitelist_recipients "$pkgdir"/etc/postfix/postgrey_whitelist_recipients
  install -D -m 0644 postgrey_whitelist_clients "$pkgdir"/etc/postfix/postgrey_whitelist_clients

  install -Dm0644 "$srcdir"/$pkgname.service "$pkgdir"/usr/lib/systemd/system/$pkgname.service
  install -Dm0644 "$srcdir"/$pkgname.sysusers "$pkgdir"/usr/lib/sysusers.d/$pkgname.conf
  install -Dm0644 "$srcdir"/$pkgname.tmpfiles "$pkgdir"/usr/lib/tmpfiles.d/$pkgname.conf
}
